package com.example.rizhaoscienceandtechnologymuseum.Utils;

import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.example.baselibrary.Utils.SelfToastUtil;
import com.example.baselibrary.Utils.StringUtil;
import com.example.rizhaoscienceandtechnologymuseum.R;

public class BottomKouLingDialog extends BottomDialogBase {

    private Context context;
    private EditText etKouLing;
    private Button btKouLing;
    public static setShowSetting setShowSetting;

    public BottomKouLingDialog(Context context) {
        super(context);

        btKouLing.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (StringUtil.isNullOrEmpty(etKouLing.getText().toString())) {
                    SelfToastUtil.getInstance().show("请输入口令");
                    return;
                }else {
                    // 如果不为空，那么就去验证
                    if (etKouLing.getText().toString().equals("1")) {
                        //那么就通过
                        setShowSetting.showSetting();
                        dismiss();
                    }else {
                        SelfToastUtil.getInstance().show("口令不正确，请联系管理员。");
                    }
                }
            }
        });
    }

    @Override
    protected void onCreate() {

        setContentView(R.layout.widget_kouling_dialog);

        etKouLing = findViewById(R.id.et_kouling_input);
        btKouLing = findViewById(R.id.bt_kouling_comfig);

    }

    public interface setShowSetting{
        void showSetting();
    }

    public static void setShowSettingListener(setShowSetting showSetting){
        setShowSetting = showSetting;
    }
}
